package com.lly.songhigh.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.lly.songhigh.fragment.DiscoverFragmentFactory;

import java.util.ArrayList;

/**
 * Created by dllo on 15/10/22.
 */
public class DiscoverFragmentAdapter extends FragmentPagerAdapter {
    ArrayList<Fragment> fragments = new ArrayList<>();

    private String [] titles = {"排行榜", "歌单", "电台", "歌手"};

    public ArrayList getFragments(){
        return fragments;
    }

    public DiscoverFragmentAdapter(FragmentManager fm) {
        super(fm);
//        fragments = new ArrayList<>();
//        fragments.add(new ChartsFragment());
//        fragments.add(new SongSheetFragment());
//        fragments.add(new RadioStationFragment());
//        fragments.add(new SingerFragment());
    }

    @Override
    public Fragment getItem(int position) {
//        Fragment fragment = fragments.get(position);
        Fragment fragment = DiscoverFragmentFactory.creatFragment(position);
        fragments.add(fragment);
        return fragment;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
